//
//  CustomAnnotationView.m
//  Meroad
//
//  Created by StariMac1 on 2019/3/20.
//  Copyright © 2019 郭孝通. All rights reserved.
//

#import "CustomAnnotationView.h"
#import "CustomTabbar.h"
#import "AppDelegate.h"

@interface CustomAnnotationView ()

@property (nonatomic, strong, readwrite)CustomCalloutView *calloutView;

@end

@implementation CustomAnnotationView

//坐标点点击事件
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    if(self.selected == selected){
        return;
    }
    
    if(selected){
        if(self.calloutView == nil){
            AppDelegate *_rootDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
            self.calloutView = [[CustomCalloutView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, ([_rootDelegate.userModel.userType isEqualToString:@"管理员"] ? 120 : 100) + myTabbarHeight)];
            [self.calloutView setToiletModel:self.model];
        }
        [self.calloutView reloadCalloutView];
        [self.delegate DidSelectedAnnotation:self.annotation];
        
        [self.calloutView show];
    }
    else{
        
        [self.calloutView hide];
        
        [self.delegate removePolyline];
    }
    
    [super setSelected:selected animated:animated];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
